package com.yzz.hzraisedust.hzraseidust.main.stastics;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yzz.hzraisedust.hzraseidust.R;
import com.yzz.hzraisedust.hzraseidust.modelbean.AirQualityBean;
import com.yzz.hzraisedust.hzraseidust.modelbean.StasticItemBean;

import java.util.List;

/**
 * Created by zhengzhen on 2017/8/23.
 */

public class StasticTodayAdapter  extends BaseAdapter{
    private List<AirQualityBean> mItems;
    private Context mContext;
    public StasticTodayAdapter(Context context,List<AirQualityBean> items){
        mContext = context;
        mItems = items;
    }
    @Override
    public int getCount() {
        return mItems.size();
    }

    @Override
    public Object getItem(int i) {
        return mItems.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
            ViewHolder viewHolder = null;
            if(view == null){
                view = LayoutInflater.from(mContext).inflate(R.layout.stastic_item_value_layout,null,false);
                viewHolder = new ViewHolder();
                viewHolder.airQualityTextView = view.findViewById(R.id.static_air_quality_textview);
                viewHolder.countTextView = view.findViewById(R.id.static_count_name_textview);
                viewHolder.countPercenteTextView = view.findViewById(R.id.static_count_percente_textview);
                view.setTag(viewHolder);
            }

            if(viewHolder == null){
                viewHolder = (ViewHolder)view.getTag();
            }

            AirQualityBean item = mItems.get(i);
            viewHolder.airQualityTextView.setText(""+item.getQualityName());
            viewHolder.countTextView.setText(""+item.getNum());
            viewHolder.countPercenteTextView.setText(""+item.getPercentage()+"%");
        return view;
    }
    class ViewHolder{
        private TextView airQualityTextView;
        private TextView countTextView;
        private  TextView countPercenteTextView;

    }
}
